package cn.cycleif.component.file;

import cn.hutool.core.date.DateUtil;
import cn.cycleif.enums.FileManageEnum;

import java.time.LocalDateTime;

/**
 * &#064;Date: 24/06/10-15:13
 * &#064;Description:
 */
public abstract class BaseFileUploadStrategy implements FileUploadStrategy {

  protected FileManageEnum storageType;
  protected String         newFileName;

  protected BaseFileUploadStrategy(FileManageEnum storageType) {
    this.storageType = storageType;
  }

  /**
   * 默认将文件名更改为时间+原文件名
   * @param key 原文件名
   */
  protected void setNewFileName(String key) {
    String format = DateUtil.format(LocalDateTime.now(), "yyyyMMddHHmmss-");
    this.newFileName = format + key;
  }

  protected abstract boolean check();

}
